package cn.chenfeifx.example.examples;

import cn.chenfeifx.core.controls.*;
import javafx.scene.Node;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.StackPane;

// 表单组件
public class FormExample extends StackPane {

    private final CFForm cfForm;

    //
    public FormExample() {
        cfForm = new CFForm();
        getChildren().add(cfForm);
        //
        cfForm.add("文本输入框", new CFTextField(CFTextField.Type.TEXT), 0);
        cfForm.add("密码输入框", new CFTextField(CFTextField.Type.PASSWORD), 1);
        ToggleGroup toggleGroup = new ToggleGroup();
        CFRadioButton radioButton1 = new CFRadioButton("RadioButton", toggleGroup);
        CFRadioButton radioButton2 = new CFRadioButton("RadioButton", true, toggleGroup);
        CFRadioButton radioButton3 = new CFRadioButton("RadioButton", true, toggleGroup);
        cfForm.addNodes("单选框", new CFRadioButton[]{radioButton1, radioButton3, radioButton2}, 2);
        cfForm.addNodes("复选框", new Node[]{new CFCheckBox("CheckBox", true),
                new CFCheckBox("CheckBox", true),
                new CFCheckBox("CheckBox")}, 3);
        cfForm.add("开关", new CFSwitch(true), 4);
    }

}